package com.yoomiito.app.ui.my.teamallowance

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import cn.droidlover.xdroidmvp.mvp.IPresent
import com.yoomiito.app.Constant
import com.yoomiito.app.R
import com.yoomiito.app.base.App
import com.yoomiito.app.model.bean.TabBean
import com.yoomiito.app.model.my.MyTodayOrderInfo
import com.yoomiito.app.ui.fragment.my.MyOrderBaseFragment
import com.yoomiito.app.ui.my.MyOrderBaseActivity
import com.yoomiito.app.utils.ResUtil

class TeamAllowanceOrderActivity :MyOrderBaseActivity<TeamAllowanceOrderPresenter>(){

    companion object{
        fun start(context: Context){
            val intent = Intent(context,TeamAllowanceOrderActivity::class.java)
            context.startActivity(intent)
        }
    }

    private val types = intArrayOf(Constant.NAMAL_TYPE_TAOBAO,  Constant.NAMAL_TYPE_GOOD)

    override fun newP(): TeamAllowanceOrderPresenter = TeamAllowanceOrderPresenter(App.mAppConfig)

    override fun initData(savedInstanceState: Bundle?) {
        super.initData(savedInstanceState)
        titleView.setCenterText("管理津贴")
        titleView.setTitleStyle()
        titleView.setRightTv("团队业绩")
        titleView.setOnRightClick {
            TeamAllowanceActivity.start(this)
        }
    }

    override fun getAllFragment(): List<MyOrderBaseFragment<*>> {
        val list = mutableListOf<MyOrderBaseFragment<*>>()
        for (type in types) {
            val orderFragment = TeamAllowanceOrderFragment()
            val goodBundle = Bundle()
            goodBundle.putInt(Constant.KEY_TYPE, type)
            orderFragment.arguments = goodBundle
            list.add(orderFragment)
        }
        return list
    }

    override fun getTabList(): List<TabBean>  = listOf(TabBean(ResUtil.getString(R.string.taobao), 0, false),
                TabBean(ResUtil.getString(R.string.my_good_goods), 0, false))


    fun setData(data: MyTodayOrderInfo){
        desTitleTv.text = "本月预计收益"
        moneyTv.text = data.teamIncome
        desTv.text="数据仅供参考，实际收益以次月月底结算为准"
    }

}